import matplotlib.pyplot as plot                                             # 调用matplotlib库
import numpy as np

x = np.linspace(-6,6,100)                                                   # x_range =（-6，6），取100个值
y = 3*x ** 2 + 4*x + 5                                                        # 自定义一个二次函数
plot.subplot(2,1,1)                                                          
plot.plot(x,y)                                                               # plot y 

plot.subplot(2,1,2)
for i in np.arange(-6,6.1,0.5):
    plot.plot([i,i],[0,i**2+2*i+3],'k')                                      # plot top and bottom
    if i < 6:
        plot.plot([i,i+0.5],[i**2+2*i+3,(i+0.5)**2+2*(i+0.5)+3],'g')         
    pass
plot.ylim(0,60)                                                              
plot.show()                                                                  #show result 